package com.da.javatest.niuke.baodian;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.stream.Collectors;

/**
 * @author chenlida
 * @date 2020/10/6 12:42
 * https://www.nowcoder.com/practice/d0d0cddc1489476da6b782a6301e7dec?tpId=8&tags=&title=&diffculty=0&judgeStatus=0&rp=1
 */
public class C16TwoStacks {
    public ArrayList<Integer> twoStacksSort(int[] numbers) {
        if (numbers == null) {
            return null;
        }
        return (ArrayList<Integer>)Arrays.stream(numbers).boxed().sorted((x, y) -> y - x).collect(Collectors.toList());
    }

    public ArrayList<Integer> twoStacksSort2(int[] numbers) {
        ArrayList<Integer> list = new ArrayList<>();
        Arrays.sort(numbers);
        for (int i = numbers.length - 1; i >= 0; i--) {
            list.add(numbers[i]);
        }
        return list;
    }
}
